BEGIN;

INSERT INTO data_classes (classname) VALUES
  ('Base'), -- 1
  ('LinkType'), -- 2
  ('DataGroup'), -- 3
  ('UserGroupPerm'); -- 4

INSERT INTO auth_user (username, first_name, last_name, email, password, is_staff, is_active, is_superuser, last_login, date_joined) VALUES
  ('testuser', 'Test', 'User', 'Test.User@example.com', 'md5$9989$'||md5('9989'||'TestUser'), true, true, false, current_timestamp, current_timestamp), -- 2
  ('testuser2', 'Test2', 'User', 'Test2.User@example.com', 'md5$9989$'||md5('9989'||'TestUser2'), true, true, false, current_timestamp, current_timestamp), -- 3
  ('testuser3', 'Test3', 'User', 'Test3.User@example.com', 'md5$9989$'||md5('9989'||'TestUser3'), true, true, false, current_timestamp, current_timestamp), -- 4
  ('testuser4', 'Test4', 'User', 'Test4.User@example.com', 'md5$9989$'||md5('9989'||'TestUser4'), true, true, false, current_timestamp, current_timestamp), -- 5
  ('testuser5', 'Test5', 'User', 'Test5.User@example.com', 'md5$9989$'||md5('9989'||'TestUser5'), true, true, false, current_timestamp, current_timestamp); -- 6

INSERT INTO auth_group (name) VALUES
  ('Public'), -- 1
  ('Admin'), -- 2
  ('TestGroup'); -- 3

COMMIT;
BEGIN;

INSERT INTO data_base (created_on, created_by_id, classname_id) VALUES
  (current_timestamp, 'testuser', 'UserGroupPerm'), -- prepare UserGroupPerm record 1 in data_usergroupperm table
  (current_timestamp, 'testuser', 'UserGroupPerm'), -- prepare UserGroupPerm record 2 in data_usergroupperm table
  (current_timestamp, 'testuser', 'UserGroupPerm'); -- prepare UserGroupPerm record 3 in data_usergroupperm table
--  (current_timestamp, 'testuser', 'UserGroupPerm'), -- prepare UserGroupPerm record 4 in data_usergroupperm table
--  (current_timestamp, 'testuser', 'UserGroupPerm'); -- prepare UserGroupPerm record 5 in data_usergroupperm table

INSERT INTO data_usergroupperm (base_ptr_id, user_id, group_id, read, write, master) VALUES
--  (1, 1, 1, true, true, true), -- admin can read, write, and master in Public
--  (2, 1, 3, true, true, true), -- admin can read, write, and master in TestGroup
  (1, 2, 3, true, true, true), -- testuser can read, write, and master in TestGroup
  (2, 3, 3, true, false, false), -- testuser2 can read in TestGroup
  (3, 4, 3, false, true, false); -- testuser3 can write in TestGroup (but not read)

COMMIT;
